const neo4j = require('neo4j-driver').v1;

const driver = neo4j.driver('bolt://127.0.0.1', neo4j.auth.basic('neo4j', '123'));

driver.onCompleted = function () {
	var session = driver.session();

	session.run('MERGE (alice:Person {name : {nameParam} }) RETURN alice.name AS name', {
		nameParam: 'Alice'
	}).subscribe({
		onNext: function (record) {
			console.log(record.get('name'));
		},
		onCompleted: function () {
			session.close();
		},
		onError: function (error) {
			console.log(error);
		}
	});
};

driver.onError = function (error) {
	console.log('Driver instantiation failed', error);
};

driver.close();
